package com.beerandjesus.sportofkings.handicapper.dao;

import com.beerandjesus.sportofkings.handicapper.model.Sire;
import com.beerandjesus.sportofkings.handicapper.model.TurfSireImpl;
import org.apache.log4j.Logger;

import java.math.BigDecimal;

/**
 * Date: Sep 8, 2012
 * Time: 6:38:05 PM
 */
public class TurfSireHibernateDAO extends SireHibernateDAO implements TurfSireDAO {

    private static final Logger LOG = Logger.getLogger(TurfSireHibernateDAO.class);

    public void buildDatabase() throws DAOException {
        buildDatabase(LEADING_TURF_SIRES, LOG);
    }

    public int getRowCount() throws DAOException {
        return getRowCount(ENTITY_CLASS.getName());
    }

    public Sire getTurfSireByName(String name) throws DAOException {
        return getSireByName(name, ENTITY_CLASS.getName());
    }

    protected Sire newSire(String name, BigDecimal percentage, BigDecimal rating) {
        Sire sire = new TurfSireImpl();
        sire.setName(name);
        sire.setWinPercentage(percentage);
        // Ignore rating for turf sires
        return sire;
    }
}
